package com.lxw.oa.controller.common;

import com.lxw.oa.controller.BaseController;
import com.lxw.oa.entity.Menu;
import com.lxw.oa.entity.User;
import com.lxw.oa.service.DataSearchService;
import com.lxw.oa.service.MenuService;
import com.lxw.oa.service.RoleService;
import com.lxw.oa.shiro.session.OnlineSessionDAO;
import com.lxw.oa.util.BackMenuUtil;
import com.lxw.oa.util.BootstrapTable;
import com.lxw.oa.util.LogAopIn;
import com.lxw.oa.util.scheduleUtil.ScheduleUtils;
import com.lxw.oa.util.scheduleUtil.SpringContextUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/search")
public class dataSearchController extends BaseController {

    @Autowired
    private DataSearchService dataSearchService;

    @Autowired
    private OnlineSessionDAO onlineSessionDAO;


    //跳转到主页面
    @LogAopIn(moduleName="数据管理-数据搜索",option="页面初始化")
    @GetMapping("/getDataSearch")
    public String Log_dataSearch()
    {
        return "pages/dataManager/mainDataSearch";
    }

    @GetMapping("/getDataByKey")
    @ResponseBody
    public Map<String, Object> getDataByKey(BootstrapTable bootstrapTable){
        //获取当前数据库下的所有表
        Map<String,Object>map=new HashMap<String,Object>();
        map.put("rows", dataSearchService.getPage(bootstrapTable));
        map.put("total", dataSearchService.getCnt(bootstrapTable));
        return map;
    }

    @LogAopIn(moduleName="数据管理-数据概括",option="页面初始化")
    @GetMapping("/getDataInduce")
    public String Log_dataInduce()
    {
        return "pages/dataManager/dataInduce";
    }


    @LogAopIn(moduleName="数据管理-数据搜索",option="页面初始化")
    @GetMapping("/toSearchIndex")
    public void Log_toHelpCenter(HttpServletResponse response) {
        try {
            response.sendRedirect("http://39.108.78.76:8888/index");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @LogAopIn(moduleName="数据管理-数据配置",option="页面初始化")
    @GetMapping("/toSearchConfig")
    public void Log_toHelpCenterUser(HttpServletResponse response) {
        try {
            response.sendRedirect("http://39.108.78.76:8888/config");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}